// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';

const { REACT_APP_ENV } = process.env;

export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  layout: {
    name: 'OPERP',
    locale: true,
    siderWidth: 208,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      layout: false,
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/welcome',
      name: 'welcome',
      icon: 'DashboardOutlined',
      component: './Welcome',
    },    
    // {
    //   name: 'list.table-list',
    //   icon: 'icon-bar_chart',
    //   path: '/list',
    //   component: './ListTableList',
    // },
    {
      path: '/account',
      name: 'account',
      icon: 'icon-businessman',
      routes: [
        {
          path: '/account/center',
          name: 'center',
          component: './account/center',
        },
        {
          path: '/account/setting',
          name: 'setting',
          component: './account/setting',
        },
      ]
    },
    {
      path: '/saleorder',
      name: 'saleorder',
      icon: 'icon-briefcase',
      authority: ['admin'],
      routes: [
        {
          path: '/saleorder/orderEntry',
          name: 'orderEntry',
          component: './saleorder/orderEntry',
        },
        {
          path: '/saleorder/quotation',
          name: 'quotation',
          component: './saleorder/quotation',
        },
        {
          path: '/saleorder/RMA',
          name: 'RMA',
          component: './saleorder/RMA',
        },
        {
          path: '/saleorder/customer',
          name: 'customer',
          component: './saleorder/customer',
        },
      ]
    },
    {
      path: '/part',
      name: 'part',
      icon: 'icon-library',
      authority: ['admin'],
      routes: [
        {
          path: '/part/partEntry',
          name: 'partEntry',
          component: './part/partEntry',
        },
        {
          path: '/part/warehse',
          name: 'warehse',
          component: './part/warehse',
        },
        {
          path: '/part/InvADJ',
          name: 'InvADJ',
          component: './part/InvADJ',
        },
        {
          path: '/part/InvCheck',
          name: 'InvCheck',
          component: './part/InvCheck',
        },
        {
          path: '/part/shipEntry',
          name: 'shipEntry',
          component: './part/shipEntry',
        },
        {
          path: '/part/rcvEntry',
          name: 'rcvEntry',
          component: './part/rcvEntry',
        },        
      ]
    },
    {
      path: '/purchase',
      name: 'purchase',
      icon: 'icon-paid',
      authority: ['admin'],
      routes: [
        {
          path: '/purchase/poSugg',
          name: 'poSugg',
          component: './purchase/poSugg',
        },
        {
          path: '/purchase/poEntry',
          name: 'poEntry',
          component: './purchase/poEntry',
        },
        {
          path: '/purchase/vendor',
          name: 'vendor',
          component: './purchase/vendor',
        },
        {
          path: '/purchase/vendorPrice',
          name: 'vendorPrice',
          component: './purchase/vendorPrice',
        },
      ]
    },
    {
      path: '/manufacture',
      name: 'manufacture',
      icon: 'icon-services',
      authority: ['admin'],
      routes: [
        {
          path: '/manufacture/jobEntry',
          name: 'jobEntry',
          component: './manufacture/jobEntry',
        },
        {
          path: '/manufacture/resourceGroup',
          name: 'resourceGroup',
          component: './manufacture/resourceGroup',
        },
        {
          path: '/manufacture/opMaster',
          name: 'opMaster',
          component: './manufacture/opMaster',
        },
        {
          path: '/manufacture/bomDesign',
          name: 'bomDesign',
          component: './manufacture/bomDesign',
        },
        {
          path: '/manufacture/mfgPlan',
          name: 'mfgPlan',
          component: './manufacture/mfgPlan',
        },
        {
          path: '/manufacture/mfgMtl',
          name: 'mfgMtl',
          component: './manufacture/mfgMtl',
        },
        {
          path: '/manufacture/MRP',
          name: 'MRP',
          component: './manufacture/MRP',
        },
      ]
    },
    {
      path: '/Inspect',
      name: 'Inspect',
      icon: 'icon-todo_list',
      authority: ['admin'],
      routes: [
        {
          path: '/Inspect/inspEntry',
          name: 'inspEntry',
          component: './Inspect/inspEntry',
        },
        {
          path: '/Inspect/dmrEntry',
          name: 'dmrEntry',
          component: './Inspect/dmrEntry',
        },
      ]
    },
    // {
    //   path: '/PayChanels',
    //   name: 'PayChanels',
    //   icon: 'icon-money_transfer',
    //   authority: ['admin'],
    //   routes: [
    //     {
    //       path: '/PayChanels/PayService',
    //       name: 'PayService',
    //       component: './PayChanels/PayService',
    //     },
    //     {
    //       path: '/PayChanels/Customers',
    //       name: 'Customers',
    //       component: './PayChanels/Customers',
    //     },
    //     {
    //       path: '/PayChanels/ChanelSetting',
    //       name: 'ChanelSetting',
    //       component: './PayChanels/ChanelSetting',
    //     },
    //     {
    //       path: '/PayChanels/UserPayChanel',
    //       name: 'UserPayChanel',
    //       component: './PayChanels/UserPayChanel',
    //     },
    //   ]
    // },
    // {
    //   path: '/opmanager',
    //   name: 'opmanager',
    //   icon: 'icon-mind_map',
    //   authority: ['admin'],
    //   routes: [
    //     {
    //       path: '/opmanager/members',
    //       name: 'members',
    //       component: './opmanager/members',
    //     },
    //   ]
    // },
    {
      path: '/admin',
      name: 'admin',
      icon: 'icon-settings',
      access: 'canAdmin',
      routes: [
        {
          path: '/admin/department',
          name: 'department',
          component: './admin/department',
        },
        {
          path: '/admin/roles',
          name: 'roles',
          component: './admin/roles',
        },
        {
          path: '/admin/tenants',
          name: 'tenants',
          component: './admin/tenants',
        },
        {
          path: '/admin/sysconfig',
          name: 'sysconfig',
          component: './admin/sysconfig',
        },
        {
          path: '/admin/files',
          name: 'files',
          component: './admin/files',
        },
      ],
    },
    {
      path: '/',
      redirect: '/welcome',
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'pre'],
  manifest: {
    basePath: '/',
  },
});
